package com.joven.security.utils;

import lombok.Data;

import java.io.Serializable;

/**
 * @Author wzj
 * @Date 2023-03-01 15:32
 **/
@Data
public class ResultData <T> implements Serializable {

    private Integer code;

    private String message;

    private T data;

    public ResultData() {
    }

    public ResultData(Integer code, String message) {
        this.code = code;
        this.message = message;
    }

    public ResultData(Integer code, String message, T data) {
        this.code = code;
        this.message = message;
        this.data = data;
    }

    public static <T> ResultData<T> success(String message, T data) {
        return new ResultData<>(0, message, data);
    }

    public static <T> ResultData<T> success(T data) {
        return new ResultData<>(0, "success", data);
    }

    public static <T> ResultData<T> success() {
        return new ResultData<>(0, "success", null);
    }

    public static <T> ResultData<T> fail(T data) {
        return new ResultData<>(111, "fail", data);
    }

    public static <T> ResultData<T> fail() {
        return new ResultData<>(111, "fail", null);
    }
}
